import http from "@/axios";
import type {PageBaseResponse, BaseResponse} from "@/api/baseResponse";
import type {PageBaseRequest} from "@/api/baseRequest";

enum ApiUrl {
    pageRetainUrl = "/retain/page",
    deleteRetainUrl = "/retain/delete"
}

export interface RetainResponse {
    topic: string;
    qos: number;
    clientId: string;
    message: string;
}

export interface PageRetainRequest extends PageBaseRequest {
    topic?: string;
}

export function pageRetain(data: PageRetainRequest) {
    return http.post<PageBaseResponse<RetainResponse[]>>(ApiUrl.pageRetainUrl, data)
}

export function deleteRetain(topic: string) {
    return http.delete<BaseResponse<boolean>>(ApiUrl.deleteRetainUrl, {
        params: {
            topic: topic
        }
    });
}